Code
from google.colab import drive
drive.mount("/content/drive")Mounted at /content/drive
from google.colab import drive
drive.mount("/content/drive")Mounted at /content/drive
!pip install quarto-cliCollecting quarto-cli
Downloading quarto_cli-1.6.42.tar.gz (4.6 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing metadata (pyproject.toml) ... done
Collecting jupyter (from quarto-cli)
Downloading jupyter-1.1.1-py2.py3-none-any.whl.metadata (2.0 kB)
Requirement already satisfied: nbclient in /usr/local/lib/python3.11/dist-packages (from quarto-cli) (0.10.2)
Requirement already satisfied: wheel in /usr/local/lib/python3.11/dist-packages (from quarto-cli) (0.45.1)
Requirement already satisfied: notebook in /usr/local/lib/python3.11/dist-packages (from jupyter->quarto-cli) (6.5.7)
Requirement already satisfied: jupyter-console in /usr/local/lib/python3.11/dist-packages (from jupyter->quarto-cli) (6.1.0)
Requirement already satisfied: nbconvert in /usr/local/lib/python3.11/dist-packages (from jupyter->quarto-cli) (7.16.6)
Requirement already satisfied: ipykernel in /usr/local/lib/python3.11/dist-packages (from jupyter->quarto-cli) (6.17.1)
Requirement already satisfied: ipywidgets in /usr/local/lib/python3.11/dist-packages (from jupyter->quarto-cli) (7.7.1)
Collecting jupyterlab (from jupyter->quarto-cli)
Downloading jupyterlab-4.4.1-py3-none-any.whl.metadata (16 kB)
Requirement already satisfied: jupyter-client>=6.1.12 in /usr/local/lib/python3.11/dist-packages (from nbclient->quarto-cli) (6.1.12)
Requirement already satisfied: jupyter-core!=5.0.*,>=4.12 in /usr/local/lib/python3.11/dist-packages (from nbclient->quarto-cli) (5.7.2)
Requirement already satisfied: nbformat>=5.1 in /usr/local/lib/python3.11/dist-packages (from nbclient->quarto-cli) (5.10.4)
Requirement already satisfied: traitlets>=5.4 in /usr/local/lib/python3.11/dist-packages (from nbclient->quarto-cli) (5.7.1)
Requirement already satisfied: pyzmq>=13 in /usr/local/lib/python3.11/dist-packages (from jupyter-client>=6.1.12->nbclient->quarto-cli) (24.0.1)
Requirement already satisfied: python-dateutil>=2.1 in /usr/local/lib/python3.11/dist-packages (from jupyter-client>=6.1.12->nbclient->quarto-cli) (2.8.2)
Requirement already satisfied: tornado>=4.1 in /usr/local/lib/python3.11/dist-packages (from jupyter-client>=6.1.12->nbclient->quarto-cli) (6.4.2)
Requirement already satisfied: platformdirs>=2.5 in /usr/local/lib/python3.11/dist-packages (from jupyter-core!=5.0.*,>=4.12->nbclient->quarto-cli) (4.3.7)
Requirement already satisfied: fastjsonschema>=2.15 in /usr/local/lib/python3.11/dist-packages (from nbformat>=5.1->nbclient->quarto-cli) (2.21.1)
Requirement already satisfied: jsonschema>=2.6 in /usr/local/lib/python3.11/dist-packages (from nbformat>=5.1->nbclient->quarto-cli) (4.23.0)
Requirement already satisfied: debugpy>=1.0 in /usr/local/lib/python3.11/dist-packages (from ipykernel->jupyter->quarto-cli) (1.8.0)
Requirement already satisfied: ipython>=7.23.1 in /usr/local/lib/python3.11/dist-packages (from ipykernel->jupyter->quarto-cli) (7.34.0)
Requirement already satisfied: matplotlib-inline>=0.1 in /usr/local/lib/python3.11/dist-packages (from ipykernel->jupyter->quarto-cli) (0.1.7)
Requirement already satisfied: nest-asyncio in /usr/local/lib/python3.11/dist-packages (from ipykernel->jupyter->quarto-cli) (1.6.0)
Requirement already satisfied: packaging in /usr/local/lib/python3.11/dist-packages (from ipykernel->jupyter->quarto-cli) (24.2)
Requirement already satisfied: psutil in /usr/local/lib/python3.11/dist-packages (from ipykernel->jupyter->quarto-cli) (5.9.5)
Requirement already satisfied: ipython-genutils~=0.2.0 in /usr/local/lib/python3.11/dist-packages (from ipywidgets->jupyter->quarto-cli) (0.2.0)
Requirement already satisfied: widgetsnbextension~=3.6.0 in /usr/local/lib/python3.11/dist-packages (from ipywidgets->jupyter->quarto-cli) (3.6.10)
Requirement already satisfied: jupyterlab-widgets>=1.0.0 in /usr/local/lib/python3.11/dist-packages (from ipywidgets->jupyter->quarto-cli) (3.0.14)
Requirement already satisfied: prompt-toolkit!=3.0.0,!=3.0.1,<3.1.0,>=2.0.0 in /usr/local/lib/python3.11/dist-packages (from jupyter-console->jupyter->quarto-cli) (3.0.51)
Requirement already satisfied: pygments in /usr/local/lib/python3.11/dist-packages (from jupyter-console->jupyter->quarto-cli) (2.18.0)
Collecting async-lru>=1.0.0 (from jupyterlab->jupyter->quarto-cli)
Downloading async_lru-2.0.5-py3-none-any.whl.metadata (4.5 kB)
Requirement already satisfied: httpx>=0.25.0 in /usr/local/lib/python3.11/dist-packages (from jupyterlab->jupyter->quarto-cli) (0.28.1)
Requirement already satisfied: jinja2>=3.0.3 in /usr/local/lib/python3.11/dist-packages (from jupyterlab->jupyter->quarto-cli) (3.1.6)
Collecting jupyter-lsp>=2.0.0 (from jupyterlab->jupyter->quarto-cli)
Downloading jupyter_lsp-2.2.5-py3-none-any.whl.metadata (1.8 kB)
Collecting jupyter-server<3,>=2.4.0 (from jupyterlab->jupyter->quarto-cli)
Downloading jupyter_server-2.15.0-py3-none-any.whl.metadata (8.4 kB)
Collecting jupyterlab-server<3,>=2.27.1 (from jupyterlab->jupyter->quarto-cli)
Downloading jupyterlab_server-2.27.3-py3-none-any.whl.metadata (5.9 kB)
Requirement already satisfied: notebook-shim>=0.2 in /usr/local/lib/python3.11/dist-packages (from jupyterlab->jupyter->quarto-cli) (0.2.4)
Requirement already satisfied: setuptools>=41.1.0 in /usr/local/lib/python3.11/dist-packages (from jupyterlab->jupyter->quarto-cli) (75.2.0)
Requirement already satisfied: beautifulsoup4 in /usr/local/lib/python3.11/dist-packages (from nbconvert->jupyter->quarto-cli) (4.13.4)
Requirement already satisfied: bleach!=5.0.0 in /usr/local/lib/python3.11/dist-packages (from bleach[css]!=5.0.0->nbconvert->jupyter->quarto-cli) (6.2.0)
Requirement already satisfied: defusedxml in /usr/local/lib/python3.11/dist-packages (from nbconvert->jupyter->quarto-cli) (0.7.1)
Requirement already satisfied: jupyterlab-pygments in /usr/local/lib/python3.11/dist-packages (from nbconvert->jupyter->quarto-cli) (0.3.0)
Requirement already satisfied: markupsafe>=2.0 in /usr/local/lib/python3.11/dist-packages (from nbconvert->jupyter->quarto-cli) (3.0.2)
Requirement already satisfied: mistune<4,>=2.0.3 in /usr/local/lib/python3.11/dist-packages (from nbconvert->jupyter->quarto-cli) (3.1.3)
Requirement already satisfied: pandocfilters>=1.4.1 in /usr/local/lib/python3.11/dist-packages (from nbconvert->jupyter->quarto-cli) (1.5.1)
Requirement already satisfied: argon2-cffi in /usr/local/lib/python3.11/dist-packages (from notebook->jupyter->quarto-cli) (23.1.0)
Requirement already satisfied: Send2Trash>=1.8.0 in /usr/local/lib/python3.11/dist-packages (from notebook->jupyter->quarto-cli) (1.8.3)
Requirement already satisfied: terminado>=0.8.3 in /usr/local/lib/python3.11/dist-packages (from notebook->jupyter->quarto-cli) (0.18.1)
Requirement already satisfied: prometheus-client in /usr/local/lib/python3.11/dist-packages (from notebook->jupyter->quarto-cli) (0.21.1)
Requirement already satisfied: nbclassic>=0.4.7 in /usr/local/lib/python3.11/dist-packages (from notebook->jupyter->quarto-cli) (1.2.0)
Requirement already satisfied: webencodings in /usr/local/lib/python3.11/dist-packages (from bleach!=5.0.0->bleach[css]!=5.0.0->nbconvert->jupyter->quarto-cli) (0.5.1)
Requirement already satisfied: tinycss2<1.5,>=1.1.0 in /usr/local/lib/python3.11/dist-packages (from bleach[css]!=5.0.0->nbconvert->jupyter->quarto-cli) (1.4.0)
Requirement already satisfied: anyio in /usr/local/lib/python3.11/dist-packages (from httpx>=0.25.0->jupyterlab->jupyter->quarto-cli) (4.9.0)
Requirement already satisfied: certifi in /usr/local/lib/python3.11/dist-packages (from httpx>=0.25.0->jupyterlab->jupyter->quarto-cli) (2025.1.31)
Requirement already satisfied: httpcore==1.* in /usr/local/lib/python3.11/dist-packages (from httpx>=0.25.0->jupyterlab->jupyter->quarto-cli) (1.0.8)
Requirement already satisfied: idna in /usr/local/lib/python3.11/dist-packages (from httpx>=0.25.0->jupyterlab->jupyter->quarto-cli) (3.10)
Requirement already satisfied: h11<0.15,>=0.13 in /usr/local/lib/python3.11/dist-packages (from httpcore==1.*->httpx>=0.25.0->jupyterlab->jupyter->quarto-cli) (0.14.0)
Collecting jedi>=0.16 (from ipython>=7.23.1->ipykernel->jupyter->quarto-cli)
Downloading jedi-0.19.2-py2.py3-none-any.whl.metadata (22 kB)
Requirement already satisfied: decorator in /usr/local/lib/python3.11/dist-packages (from ipython>=7.23.1->ipykernel->jupyter->quarto-cli) (4.4.2)
Requirement already satisfied: pickleshare in /usr/local/lib/python3.11/dist-packages (from ipython>=7.23.1->ipykernel->jupyter->quarto-cli) (0.7.5)
Requirement already satisfied: backcall in /usr/local/lib/python3.11/dist-packages (from ipython>=7.23.1->ipykernel->jupyter->quarto-cli) (0.2.0)
Requirement already satisfied: pexpect>4.3 in /usr/local/lib/python3.11/dist-packages (from ipython>=7.23.1->ipykernel->jupyter->quarto-cli) (4.9.0)
Requirement already satisfied: attrs>=22.2.0 in /usr/local/lib/python3.11/dist-packages (from jsonschema>=2.6->nbformat>=5.1->nbclient->quarto-cli) (25.3.0)
Requirement already satisfied: jsonschema-specifications>=2023.03.6 in /usr/local/lib/python3.11/dist-packages (from jsonschema>=2.6->nbformat>=5.1->nbclient->quarto-cli) (2024.10.1)
Requirement already satisfied: referencing>=0.28.4 in /usr/local/lib/python3.11/dist-packages (from jsonschema>=2.6->nbformat>=5.1->nbclient->quarto-cli) (0.36.2)
Requirement already satisfied: rpds-py>=0.7.1 in /usr/local/lib/python3.11/dist-packages (from jsonschema>=2.6->nbformat>=5.1->nbclient->quarto-cli) (0.24.0)
Collecting jupyter-client>=6.1.12 (from nbclient->quarto-cli)
Downloading jupyter_client-7.4.9-py3-none-any.whl.metadata (8.5 kB)
Collecting jupyter-events>=0.11.0 (from jupyter-server<3,>=2.4.0->jupyterlab->jupyter->quarto-cli)
Downloading jupyter_events-0.12.0-py3-none-any.whl.metadata (5.8 kB)
Collecting jupyter-server-terminals>=0.4.4 (from jupyter-server<3,>=2.4.0->jupyterlab->jupyter->quarto-cli)
Downloading jupyter_server_terminals-0.5.3-py3-none-any.whl.metadata (5.6 kB)
Collecting overrides>=5.0 (from jupyter-server<3,>=2.4.0->jupyterlab->jupyter->quarto-cli)
Downloading overrides-7.7.0-py3-none-any.whl.metadata (5.8 kB)
Requirement already satisfied: websocket-client>=1.7 in /usr/local/lib/python3.11/dist-packages (from jupyter-server<3,>=2.4.0->jupyterlab->jupyter->quarto-cli) (1.8.0)
Requirement already satisfied: entrypoints in /usr/local/lib/python3.11/dist-packages (from jupyter-client>=6.1.12->nbclient->quarto-cli) (0.4)
Requirement already satisfied: argon2-cffi-bindings in /usr/local/lib/python3.11/dist-packages (from argon2-cffi->notebook->jupyter->quarto-cli) (21.2.0)
Requirement already satisfied: babel>=2.10 in /usr/local/lib/python3.11/dist-packages (from jupyterlab-server<3,>=2.27.1->jupyterlab->jupyter->quarto-cli) (2.17.0)
Collecting json5>=0.9.0 (from jupyterlab-server<3,>=2.27.1->jupyterlab->jupyter->quarto-cli)
Downloading json5-0.12.0-py3-none-any.whl.metadata (36 kB)
Requirement already satisfied: requests>=2.31 in /usr/local/lib/python3.11/dist-packages (from jupyterlab-server<3,>=2.27.1->jupyterlab->jupyter->quarto-cli) (2.32.3)
Requirement already satisfied: wcwidth in /usr/local/lib/python3.11/dist-packages (from prompt-toolkit!=3.0.0,!=3.0.1,<3.1.0,>=2.0.0->jupyter-console->jupyter->quarto-cli) (0.2.13)
Requirement already satisfied: six>=1.5 in /usr/local/lib/python3.11/dist-packages (from python-dateutil>=2.1->jupyter-client>=6.1.12->nbclient->quarto-cli) (1.17.0)
Requirement already satisfied: ptyprocess in /usr/local/lib/python3.11/dist-packages (from terminado>=0.8.3->notebook->jupyter->quarto-cli) (0.7.0)
Requirement already satisfied: soupsieve>1.2 in /usr/local/lib/python3.11/dist-packages (from beautifulsoup4->nbconvert->jupyter->quarto-cli) (2.7)
Requirement already satisfied: typing-extensions>=4.0.0 in /usr/local/lib/python3.11/dist-packages (from beautifulsoup4->nbconvert->jupyter->quarto-cli) (4.13.2)
Requirement already satisfied: sniffio>=1.1 in /usr/local/lib/python3.11/dist-packages (from anyio->httpx>=0.25.0->jupyterlab->jupyter->quarto-cli) (1.3.1)
Requirement already satisfied: parso<0.9.0,>=0.8.4 in /usr/local/lib/python3.11/dist-packages (from jedi>=0.16->ipython>=7.23.1->ipykernel->jupyter->quarto-cli) (0.8.4)
Collecting python-json-logger>=2.0.4 (from jupyter-events>=0.11.0->jupyter-server<3,>=2.4.0->jupyterlab->jupyter->quarto-cli)
Downloading python_json_logger-3.3.0-py3-none-any.whl.metadata (4.0 kB)
Requirement already satisfied: pyyaml>=5.3 in /usr/local/lib/python3.11/dist-packages (from jupyter-events>=0.11.0->jupyter-server<3,>=2.4.0->jupyterlab->jupyter->quarto-cli) (6.0.2)
Collecting rfc3339-validator (from jupyter-events>=0.11.0->jupyter-server<3,>=2.4.0->jupyterlab->jupyter->quarto-cli)
Downloading rfc3339_validator-0.1.4-py2.py3-none-any.whl.metadata (1.5 kB)
Collecting rfc3986-validator>=0.1.1 (from jupyter-events>=0.11.0->jupyter-server<3,>=2.4.0->jupyterlab->jupyter->quarto-cli)
Downloading rfc3986_validator-0.1.1-py2.py3-none-any.whl.metadata (1.7 kB)
Requirement already satisfied: charset-normalizer<4,>=2 in /usr/local/lib/python3.11/dist-packages (from requests>=2.31->jupyterlab-server<3,>=2.27.1->jupyterlab->jupyter->quarto-cli) (3.4.1)
Requirement already satisfied: urllib3<3,>=1.21.1 in /usr/local/lib/python3.11/dist-packages (from requests>=2.31->jupyterlab-server<3,>=2.27.1->jupyterlab->jupyter->quarto-cli) (2.3.0)
Requirement already satisfied: cffi>=1.0.1 in /usr/local/lib/python3.11/dist-packages (from argon2-cffi-bindings->argon2-cffi->notebook->jupyter->quarto-cli) (1.17.1)
Requirement already satisfied: pycparser in /usr/local/lib/python3.11/dist-packages (from cffi>=1.0.1->argon2-cffi-bindings->argon2-cffi->notebook->jupyter->quarto-cli) (2.22)
Collecting fqdn (from jsonschema[format-nongpl]>=4.18.0->jupyter-events>=0.11.0->jupyter-server<3,>=2.4.0->jupyterlab->jupyter->quarto-cli)
Downloading fqdn-1.5.1-py3-none-any.whl.metadata (1.4 kB)
Collecting isoduration (from jsonschema[format-nongpl]>=4.18.0->jupyter-events>=0.11.0->jupyter-server<3,>=2.4.0->jupyterlab->jupyter->quarto-cli)
Downloading isoduration-20.11.0-py3-none-any.whl.metadata (5.7 kB)
Requirement already satisfied: jsonpointer>1.13 in /usr/local/lib/python3.11/dist-packages (from jsonschema[format-nongpl]>=4.18.0->jupyter-events>=0.11.0->jupyter-server<3,>=2.4.0->jupyterlab->jupyter->quarto-cli) (3.0.0)
Collecting uri-template (from jsonschema[format-nongpl]>=4.18.0->jupyter-events>=0.11.0->jupyter-server<3,>=2.4.0->jupyterlab->jupyter->quarto-cli)
Downloading uri_template-1.3.0-py3-none-any.whl.metadata (8.8 kB)
Requirement already satisfied: webcolors>=24.6.0 in /usr/local/lib/python3.11/dist-packages (from jsonschema[format-nongpl]>=4.18.0->jupyter-events>=0.11.0->jupyter-server<3,>=2.4.0->jupyterlab->jupyter->quarto-cli) (24.11.1)
Collecting arrow>=0.15.0 (from isoduration->jsonschema[format-nongpl]>=4.18.0->jupyter-events>=0.11.0->jupyter-server<3,>=2.4.0->jupyterlab->jupyter->quarto-cli)
Downloading arrow-1.3.0-py3-none-any.whl.metadata (7.5 kB)
Collecting types-python-dateutil>=2.8.10 (from arrow>=0.15.0->isoduration->jsonschema[format-nongpl]>=4.18.0->jupyter-events>=0.11.0->jupyter-server<3,>=2.4.0->jupyterlab->jupyter->quarto-cli)
Downloading types_python_dateutil-2.9.0.20241206-py3-none-any.whl.metadata (2.1 kB)
Downloading jupyter-1.1.1-py2.py3-none-any.whl (2.7 kB)
Downloading jupyterlab-4.4.1-py3-none-any.whl (12.3 MB)
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā 12.3/12.3 MB 73.8 MB/s eta 0:00:00
Downloading async_lru-2.0.5-py3-none-any.whl (6.1 kB)
Downloading jupyter_lsp-2.2.5-py3-none-any.whl (69 kB)
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā 69.1/69.1 kB 5.2 MB/s eta 0:00:00
Downloading jupyter_server-2.15.0-py3-none-any.whl (385 kB)
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā 385.8/385.8 kB 24.5 MB/s eta 0:00:00
Downloading jupyter_client-7.4.9-py3-none-any.whl (133 kB)
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā 133.5/133.5 kB 9.1 MB/s eta 0:00:00
Downloading jupyterlab_server-2.27.3-py3-none-any.whl (59 kB)
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā 59.7/59.7 kB 4.3 MB/s eta 0:00:00
Downloading jedi-0.19.2-py2.py3-none-any.whl (1.6 MB)
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā 1.6/1.6 MB 50.7 MB/s eta 0:00:00
Downloading json5-0.12.0-py3-none-any.whl (36 kB)
Downloading jupyter_events-0.12.0-py3-none-any.whl (19 kB)
Downloading jupyter_server_terminals-0.5.3-py3-none-any.whl (13 kB)
Downloading overrides-7.7.0-py3-none-any.whl (17 kB)
Downloading python_json_logger-3.3.0-py3-none-any.whl (15 kB)
Downloading rfc3986_validator-0.1.1-py2.py3-none-any.whl (4.2 kB)
Downloading rfc3339_validator-0.1.4-py2.py3-none-any.whl (3.5 kB)
Downloading fqdn-1.5.1-py3-none-any.whl (9.1 kB)
Downloading isoduration-20.11.0-py3-none-any.whl (11 kB)
Downloading uri_template-1.3.0-py3-none-any.whl (11 kB)
Downloading arrow-1.3.0-py3-none-any.whl (66 kB)
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā 66.4/66.4 kB 4.7 MB/s eta 0:00:00
Downloading types_python_dateutil-2.9.0.20241206-py3-none-any.whl (14 kB)
Building wheels for collected packages: quarto-cli
Building wheel for quarto-cli (pyproject.toml) ... done
Created wheel for quarto-cli: filename=quarto_cli-1.6.42-py3-none-any.whl size=129963247 sha256=111a76fdd34ea7d592ef927616bca3768d718be84aac1c917d0fafaac140e9ab
Stored in directory: /root/.cache/pip/wheels/08/53/61/bfcee646357ada471f314e1733d7306818bdd55d48ef8f830f
Successfully built quarto-cli
Installing collected packages: uri-template, types-python-dateutil, rfc3986-validator, rfc3339-validator, python-json-logger, overrides, json5, jedi, fqdn, async-lru, jupyter-server-terminals, jupyter-client, arrow, isoduration, jupyter-events, jupyter-server, jupyterlab-server, jupyter-lsp, jupyterlab, jupyter, quarto-cli
Attempting uninstall: jupyter-client
Found existing installation: jupyter-client 6.1.12
Uninstalling jupyter-client-6.1.12:
Successfully uninstalled jupyter-client-6.1.12
Attempting uninstall: jupyter-server
Found existing installation: jupyter-server 1.16.0
Uninstalling jupyter-server-1.16.0:
Successfully uninstalled jupyter-server-1.16.0
Successfully installed arrow-1.3.0 async-lru-2.0.5 fqdn-1.5.1 isoduration-20.11.0 jedi-0.19.2 json5-0.12.0 jupyter-1.1.1 jupyter-client-7.4.9 jupyter-events-0.12.0 jupyter-lsp-2.2.5 jupyter-server-2.15.0 jupyter-server-terminals-0.5.3 jupyterlab-4.4.1 jupyterlab-server-2.27.3 overrides-7.7.0 python-json-logger-3.3.0 quarto-cli-1.6.42 rfc3339-validator-0.1.4 rfc3986-validator-0.1.1 types-python-dateutil-2.9.0.20241206 uri-template-1.3.0
import pandas as pd
import plotnine as p9
from plotnine import *
import numpy as npindicator_1 = pd.read_csv("unicef_indicator_1.csv")
metadata = pd.read_csv("unicef_metadata.csv")indicator_1 = indicator_1[indicator_1['sex'] == 'Total']
indicator_1 = indicator_1.rename(columns={'country': 'Country', 'time_period': 'Year', 'obs_value': 'Value'})
indicator_1 = indicator_1[['Country', 'Year', 'Value']]top_n = 10
top_countries = indicator_1.nlargest(top_n, 'Value')
bar_chart = (
ggplot(top_countries, aes(x='Country', y='Value'))
+ geom_bar(stat='identity', fill='steelblue')
+ coord_flip()
+ theme_minimal()
+ labs(title=f'Top {top_n} Countries by Child Deprivation Index')
)
bar_chart # This will display the chart###š The bar chart illustrates the top 10 countries by Child Deprivation Index. Madagascar has the highest deprivation, followed by Ethiopia, Chad, and Cambodia. Other countries on the list include Niger, Mozambique, Mauritania, Liberia, Benin, and Angola. Most of these countries are in Africa, highlighting significant regional disparities in child wellbeing.
import pandas as pd
from plotnine import ggplot, aes, geom_line, geom_point, theme_minimal, labs
# Load your datasets
indicator_1 = pd.read_csv("unicef_indicator_1.csv")
metadata = pd.read_csv("unicef_metadata.csv")
# Clean indicator_1 data
indicator_1 = indicator_1[indicator_1['sex'] == 'Total']
indicator_1 = indicator_1.rename(columns={'country': 'Country', 'time_period': 'Year', 'obs_value': 'Value'})
indicator_1 = indicator_1[['Country', 'Year', 'Value']]
# Get top countries from indicator data based on average 'Value'
top_countries = indicator_1.groupby('Country')['Value'].mean().nlargest(10).index.tolist()
# Filter the indicator data for only the top countries
multi_country_data = indicator_1[indicator_1['Country'].isin(top_countries)]
# Create a time series chart for the top countries
multi_time_series_chart = (
ggplot(multi_country_data, aes(x='Year', y='Value', color='Country'))
+ geom_line()
+ geom_point()
+ theme_minimal()
+ labs(
title='Child Deprivation Index Over Time: Top 10 Countries',
x='Year',
y='Deprivation Index'
)
)
multi_time_series_chart # Display the chart/usr/local/lib/python3.11/dist-packages/plotnine/geoms/geom_path.py:113: PlotnineWarning: geom_path: Each group consist of only one observation. Do you need to adjust the group aesthetic?
##š Child Deprivation Index Over Time: Top 10 Countries
!pip install plotly
import plotly.express as pxRequirement already satisfied: plotly in /usr/local/lib/python3.11/dist-packages (5.24.1)
Requirement already satisfied: tenacity>=6.2.0 in /usr/local/lib/python3.11/dist-packages (from plotly) (9.1.2)
Requirement already satisfied: packaging in /usr/local/lib/python3.11/dist-packages (from plotly) (24.2)
fig = px.choropleth(indicator_1,
locations="Country",
locationmode='country names',
color="Value",
title="Child Deprivation Index by Country")
fig.show()scatter_plot = (
ggplot(indicator_1, aes(x='Year', y='Value'))
+ geom_point()
+ geom_smooth(method='lm', color='red')
+ labs(title='Child Deprivation Over Time', x='Year', y='Deprivation Index')
+ theme_minimal()
)
print(scatter_plot) # This will display the chart<ggplot: (640 x 480)>
scatter_plot